﻿appRoot.controller('FusionController', function ($scope, $location, $resource) {

    var fResource = $resource('/api/fusion', {}, { get: { method: 'GET' }, update: { method: 'POST' } });

    $scope.getFusionParameter = function () {
        $scope.fusionParameter = fResource.get({});
    };

    $scope.updateFusion = function (parameter) {

        fResource.update(parameter, function success(parameter) {
            $scope.fusionParameter.sic = parameter.sic;
            $scope.fusionParameter.sac = parameter.sac;
            $scope.fusionParameter.posResolution = parameter.posResolution;
            $scope.fusionParameter.altResolution = parameter.altResolution;
            $scope.fusionParameter.fusionRate = parameter.fusionRate;
            $scope.fusionParameter.predictionTime = parameter.predictionTime;

            setTimeout(function () {
                $.Notify({
                    style: {
                        background: 'green',
                        color: 'white'
                    },
                    shadow: true,
                    position: 'bottom-left',
                    caption: 'Data Fusion',
                    content: "Configuration has been updated succesfully."
                });
            }, 1000);
        }, function error() {
            setTimeout(function () {
                $.Notify({
                    style: {
                        background: 'red',
                        color: 'white'
                    },
                    shadow: true,
                    position: 'bottom-left',
                    caption: 'Data Fusion',
                    content: "Configuration cannot be updated."
                });
            }, 1000);
        });
    };
});